<template>
  <div class="videoPlay" id="videoPlayEnt"></div>
</template>
<script>
import axios from "axios";
export default {
  name: "videoPlayEnt",
  components: {},
  data() {
    return {
      szIP1: "192.168.26.40", //设备的ip地址
      iPrototocal: 1, //1是http协议，2是https协议
      iPort1: "80", //登录设备的端口号
      szUserName: "admin", //登录用户名称,
      szPassword: "Hik12345", //用户密码

      szIP2: "", //设备的ip地址
      iPort2: "80", //登录设备的端口号
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      window.WebVideoCtrl.I_InitPlugin({
        bWndFull: true, //是否支持单窗口双击全屏，默认支持 true:支持 false:不支持
        iWndowType: 1,
        // cbSelWnd: function (xmlDoc) {},
        // cbDoubleClickWnd: function (iWndIndex, bFullScreen) {},
        // cbEvent: function (iEventType, iParam1, iParam2) {},
        cbInitPluginComplete: () => {
          window.WebVideoCtrl.I_InsertOBJECTPlugin("videoPlayEnt").then(
            () => {
              // 检查插件是否最新
              window.WebVideoCtrl.I_CheckPluginVersion().then((bFlag) => {
                if (bFlag) {
                  alert(
                    "检测到新的插件版本，双击开发包目录里的HCWebSDKPlugin.exe升级！"
                  );
                }
                // this.login()
              });
              window.WebVideoCtrl.I_ArrangeWindow("1*2");
            },
            () => {
              alert(
                "插件初始化失败，请确认是否已安装插件；如果未安装，请双击开发包目录里的HCWebSDKPlugin.exe安装！"
              );
            }
          );
        },
      });
    },
    login() {
      WebVideoCtrl.I_Login(
        this.szIP1,
        this.iPrototocal,
        this.iPort1,
        this.szUserName,
        this.szPassword,
        {
          timeout: 3000,
          success: () => {
            showOPInfo(" 登录成功！");
            this.see();
          },
          error: () => {},
        }
      );
    },

    see() {
      //开始预览
      //   I_StartPlay()  I_StartRealPlay
      WebVideoCtrl.I_StartPlay(this.szIP1 + "_" + this.iPort1, {
        iWndIndex: "", //播放窗口
        szUrl: "", //地址
        success: function () {},
        error: function (oError) {},
      });
    },
    playVideo() {},
    pauseVideo() {},
  },
};
</script>
<style lang="less">
.videoPlay {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  background: #2a2b2c;
}
</style>
